const get_type_color = (label: string) => {
  label = label.toUpperCase();
  let color = "#5aa4ae";
  if (label.indexOf("I2C") != -1) color = "#5976ba";
  if (label.indexOf("SPI") != -1) color = "#422256";
  if (label.indexOf("DAP") != -1) color = "#bd8253";
  if (label.indexOf("WAKEUP") != -1) color = "#4c8045";
  if (label.indexOf("ADC") != -1) color = "#7e9dfb";
  if (label.indexOf("PWM") != -1) color = "#9d65eb";
  return color;
};

const get_adc_channels = (chip_name: string) => {
  chip_name = chip_name.toLowerCase();
  if (chip_name == "esp32")
    return [
      { label: "ADC1_CH0", io: 36 },
      { label: "ADC1_CH1", io: 37 },
      { label: "ADC1_CH2", io: 38 },
      { label: "ADC1_CH3", io: 39 },
      { label: "ADC1_CH4", io: 32 },
      { label: "ADC1_CH5", io: 33 },
      { label: "ADC1_CH6", io: 34 },
      { label: "ADC1_CH7", io: 35 },
    ];
  else if (chip_name == "esp32s2" || chip_name == "esp32s3")
    return [
      { label: "ADC1_CH0", io: 1 },
      { label: "ADC1_CH1", io: 2 },
      { label: "ADC1_CH2", io: 3 },
      { label: "ADC1_CH3", io: 4 },
      { label: "ADC1_CH4", io: 5 },
      { label: "ADC1_CH5", io: 6 },
      { label: "ADC1_CH6", io: 7 },
      { label: "ADC1_CH7", io: 8 },
      { label: "ADC1_CH8", io: 9 },
      { label: "ADC1_CH9", io: 10 },
    ];
  else if (chip_name == "esp32c2" || chip_name == "esp32c3")
    return [
      { label: "ADC1_CH0", io: 0 },
      { label: "ADC1_CH1", io: 1 },
      { label: "ADC1_CH2", io: 2 },
      { label: "ADC1_CH3", io: 3 },
      { label: "ADC1_CH4", io: 4 },
    ];
  else if (chip_name == "esp32h2")
    return [
      { label: "ADC1_CH0", io: 1 },
      { label: "ADC1_CH1", io: 2 },
      { label: "ADC1_CH2", io: 3 },
      { label: "ADC1_CH3", io: 4 },
      { label: "ADC1_CH4", io: 5 },
    ];
  else if (chip_name == "esp32c6")
    return [
      { label: "ADC1_CH0", io: 0 },
      { label: "ADC1_CH1", io: 1 },
      { label: "ADC1_CH2", io: 2 },
      { label: "ADC1_CH3", io: 3 },
      { label: "ADC1_CH4", io: 4 },
      { label: "ADC1_CH5", io: 5 },
      { label: "ADC1_CH6", io: 6 },
    ];
  else if (chip_name == "esp32p4")
    return [
      { label: "ADC1_CH0", io: 16 },
      { label: "ADC1_CH1", io: 17 },
      { label: "ADC1_CH2", io: 18 },
      { label: "ADC1_CH3", io: 19 },
      { label: "ADC1_CH4", io: 20 },
      { label: "ADC1_CH5", io: 21 },
      { label: "ADC1_CH6", io: 22 },
      { label: "ADC1_CH7", io: 23 },
      { label: "ADC1_CH8", io: 49 },
      { label: "ADC1_CH9", io: 50 },
      { label: "ADC1_CH10", io: 51 },
      { label: "ADC1_CH11", io: 52 },
      { label: "ADC1_CH12", io: 53 },
      { label: "ADC1_CH13", io: 54 },
    ];
  return [];
};

const tools = {
  get_type_color,
  get_adc_channels,
};

export default tools;
